var http = require('http');
var fs = require('fs');
var sys = require("sys");
//npm install socket.io
//npm install jquery
  

http.createServer(function (req, res) {
  
  if(req.url == '/'){
  	res.writeHead(404, {'Content-Type': 'text/html'});
  	res.end('<h1>Sou mais BAHEEAAA!!!</h1>\n');
  }else{
      	
    fs.readFile(__dirname + '/style.css' ,function(err,data){ console.log(data); });

    fs.readFile(__dirname + '/index.html',function(err,data){
  		if(err){
  			res.writeHead(500);
  			return res.end('Error');	
  		}
  		
      res.writeHead(200);
  		
      data = data.toString().replace('{{nome}}',req.url.substring(1));
    	res.end(data);
  	});
  	
  }
  	

}).listen(1337, '127.0.0.1');
console.log('servidor rodando em http://127.0.0.1:1337/');